<?php

class articleComponents extends sfComponents {
    public function executeRecommend_comment( sfWebRequest $request ) {
        $this->recommend_comments = Doctrine::getTable('ArticleComment')->createQuery()->where('display = ?',1)->andWhere('recommend = ?',1)->orderBy('recommend_time desc')->limit(3)->execute();
    }
    
    public function executeHot_articles(sfWebRequest $request ){
        //@duto:不显示文章过滤
        $this->first_articles = Doctrine::getTable('ArticleAttribute')->createQuery()->where('display = ?',1)->orderBy('click desc')->execute()->getFirst();
        $this->hot_articles = Doctrine::getTable('ArticleAttribute')->createQuery()->where('display = ?',1)->orderBy('click desc')->offset(1)->limit(5)->execute();
    }
    
    public function executeComment(sfWebRequest $request){
        
    }
    
    public function executeAuthor_list(sfWebRequest $request){
        $this->authors = Doctrine::getTable('ArticleAuthor')->createQuery()->orderBy('article_num desc')->limit(4)->execute();
    }
    
    public function executeRecommend(sfWebRequest $request){
        
    }
    
    //首页精彩文章
    public function executeDefault_maxread_list(sfWebRequest $request){
       $this->articles = Doctrine::getTable('ArticleAttribute')->createQuery()->where('display = 1')->orderBy('click desc')->limit(9)->execute();
    }
    
    public function executeAuthor_other_article(sfWebRequest $request){
        $author_obj = $this->getVar('author');
        $current_article_id = $this->getVar('current_article_id');
        $other_ids = array($current_article_id);
        $this->first_one = Doctrine::getTable('Article')->createQuery()->where('display = 1')->andWhere('author = ?',$author_obj->getId())->andWhereNotIn('id',$other_ids)->orderBy('created_at desc')->fetchOne();
        $other_ids[] = $this->first_one['id'];
        $this->other_articles = Doctrine::getTable('Article')->createQuery()->where('display = 1')->andWhere('author = ?',$author_obj->getId())->andWhereNotIn('id',$other_ids)->orderBy('created_at desc')->offset(1)->limit(4)->execute();
    }
    
    
}
?>
